
<div class="main layui-clear">
    <div class="wrap">
        <div class="content detail">
        <?php if ($res){ ?>
            
        <?php } ?>
            <div class="fly-panel detail-box">
                <h1>
                   <?php echo $res['title'] ?>
                </h1>
                <div class="fly-tip fly-detail-hint">
                    <span>
                        <?php echo $res['status'] ?>
                    </span>
                    <div class="jie-admin-box" data-id="8970">
                    </div>
                    <div class="fly-list-hint">
                        <a href="#comment">
                            <i class="iconfont" title="回答">
                                
                            </i>
                            <?php echo $res['answer_num'] ?>
                        </a>
                        <i class="iconfont" title="人气">
                            
                        </i>
                        <?php echo $res['view_num'] ?>
                    </div>
                </div>
                <div class="detail-about">
                    <a class="jie-user" href="{:U('home/u/index',array('id'=>$res['uid']))}">
                        <img src="__ROOT__/<?php echo $res['face'] ?>"
                        alt="zhens">
                        <cite>
                            <?php echo $res['nickname'] ?>
                            <em>
                                 发布时间：<?php echo date("Y.m.d h.i.s",$res['create_time']) ?>
                            </em>
                        </cite>
                    </a>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="8970">
                        <span style="color:#FF7200">
                            悬赏:<?php echo $res['kiss_num']; ?>飞吻
                        </span>
                        <span class="layui-btn layui-btn-mini jie-admin " type="collect" data-type="add">
                            收藏
                        </span>
                    </div>
                </div>
                <div class="detail-body photos">
                   <?php echo htmlspecialchars_decode($res['content']); ?>
                </div>
            </div>            <div class="fly-panel detail-box" style="padding-top: 0;">
                <ul class="jieda photos" id="jieda">
                   <?php if (empty($answer)) { ?>
                    <li class="fly-none">
                        没有任何回答
                    </li>
                   <?php }else{ ?>
                        <?php foreach ($answer as $v) { ?>
                           <li data-id="29047">
                            <a name="item-1490164910627">
                            </a>
                            <div class="detail-about detail-about-reply">
                                <a class="jie-user" href="{:U('home/u/index',array('id'=>$v['uid']))}">
                                    <img src="__ROOT__/<?php echo $v['face'] ?>"
                                    alt="带头哥" layer-index="2">
                                    <cite>
                                        <i class="name">
                                            <?php echo $v['nickname'] ?>
                                        </i>
                                    </cite>
                                </a>
                                <div class="detail-hits">
                                    <span>
                                        <?php echo date("Y.m.d h.i.s",$v['create_time']) ?>
                                    </span>
                                </div>
                            </div>
                            <div class="detail-body jieda-body">
                                <?php echo htmlspecialchars_decode($v['content']) ?>
                            </div>
                            <div class="jieda-reply">
                                <span class="jieda-zan " type="zan">
                                    <i class="iconfont icon-zan">
                                    </i>
                                    <em>
                                        0
                                    </em>
                                </span>
                                <span type="reply" class="hf" nickname="<?php echo $v['nickname'] ?>">
                                    <i class="iconfont icon-svgmoban53 ">
                                    </i>
                                    回复
                                </span>
                            </div>
                        </li>
                       <?php } ?>
                    <?php } ?>
                </ul>
                <div class="layui-form layui-form-pane">
                    <form action="/jie/reply/" method="post">
                        <div class="layui-form-item layui-form-text">
                            <a name="comment">
                            </a>
                            <div class="layui-input-block">
                                <textarea id="L_content" name="content" required="" placeholder="我要回答" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <input type="hidden" name="qid" value="<?php echo  $res['id'] ?>">
                            <button class="layui-btn" lay-filter="update" lay-submit="">
                                提交回答
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="edge">

       <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                最近热帖
            </dt>
            <?php foreach ($arr as $v) { ?>
            <dd>
                <a href="{:U('home/Publish/homepage',array('id'=>$v['id']))}">
                   <?php echo $v['title'] ?>
                </a>
                <span>
                    <i class="iconfont">
                        
                    </i>
                    <?php echo $v['view_num'] ?>
                </span>
            </dd>
            <?php } ?>
        </dl>
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                    近期热议
                </dt>
            <?php foreach ($row as $v) { ?>
                
                <dd>
                    <a href="{:U('home/Publish/homepage',array('id'=>$v['id']))}">
                        <?php echo $v['title'] ?>
                    </a>
                    <span>
                        <i class="iconfont">
                            
                        </i>
                        <?php echo $v['answer_num'] ?>
                    </span>
                </dd>
            <?php } ?>
                
        </dl>
       
    </div>
</div>
<script type="text/javascript">
    layui.use(['form','jquery','layedit'], function(){
        var form = layui.form()
        ,layer = layui.layer,
        $= layui.jquery;
        layedit = layui.layedit;


      
        //
        //
        layedit.set({
          uploadImage: {
            url: '{:U('home/Publish/img')}' //接口url
            ,type: '' //默认post
          }
        });
        index = layedit.build('L_content', {
          height: 180 //设置编辑器高度
        });


        $('.hf').click(function(event) {
            nickname = $(this).attr('nickname');
            nickname = "@"+nickname;

            $('#L_content').html(nickname);

            index = layedit.build('L_content', {
              height: 180 //设置编辑器高度
            });
        });
              //监听提交
        form.on('submit(update)', function(data){
            console.log(data);

            content = layedit.getContent(index);
            if (content.length<1) {
                 layer.msg('内容不能少于20', function(){}
                    );
            };

            data.field.content = content;
            $.ajax({
                url: '{:U('home/Publish/check')}',
                type: 'POST',
                dataType: 'json',
                data: data.field,
            })
            .done(function(respones) {
                if(respones.error==1){
                    layer.msg(respones.info, function(){}
                    );
                }else if(respones.error==0){
                    layer.alert(respones.info, {icon: 6},function  () {
                        location.reload();
                    });
                }else{
                    layer.alert(respones.info, {icon: 6},function  () {
                        location.replace(respones.url);
                    });
                }
            })
            .fail(function() {
                console.log("error");
            })
        
      
        return false;

        });
  
  
    });
</script>